package com.ykt.converter;

import com.ykt.model.Community;
import com.ykt.vo.CommunityVo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author long.hua
 * @version 1.0.0
 * @since 2016-04-17 11:11
 */
public class CommunityConverter {


    public static CommunityVo convert(Community model){
        if(model == null){
            return null;
        }

        CommunityVo vo = new CommunityVo();
        vo.setId(model.getId());
        vo.setName(model.getName());
        vo.setAddress(model.getStr(Community.address));
        vo.setContactsName(model.getStr(Community.contacts_name));
        vo.setContactsPhone(model.getStr(Community.contacts_phone));

        return vo;
    }


    public static List<CommunityVo> convert(List<Community> models){
        if(models == null || models.isEmpty()){
            return null;
        }

        List<CommunityVo> vos = new ArrayList<>();
        for (Community model : models) {
            vos.add(convert(model));
        }

        return vos;
    }
}
